package com.zx.idc.backend.gui.api.ftp.sftp;

import com.jcraft.jsch.ChannelSftp;
import com.zx.idc.common.pool.Pool;

/**
 * @author rxliuli
 */
public class SftpChannelSftpValidator implements Pool.Validator<ChannelSftp> {
    @Override
    public boolean valid(ChannelSftp sftp) {
        return sftp != null && sftp.isConnected() && !sftp.isClosed();
    }

    @Override
    public void invalidate(ChannelSftp sftp) {
        if (sftp != null) {
            sftp.disconnect();
        }
    }
}
